﻿using ChestPainCenterSystem.Core;
using ChestPainCenterSystem.MedicalConfig;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ChestPainCenterSystem.Bll
{
    public class MedicalRecordSetManager : BaseManager
    {
        /// <summary>
        /// 获取病历主题
        /// </summary>
        /// <param name="medicalId"></param>
        /// <returns></returns>
        public static OperateResult GetMedicalConfig(int medicalId)
        {
            OperateResult resultInfo = new OperateResult();
            try
            {
                Medical_ConfigSoapClient service = new Medical_ConfigSoapClient();
                ResultHelperOfString result = service.GetBase_Medical_ConfigByMedical_ID(medicalId);
                if (result.S)
                {
                    resultInfo.Body = result.D;
                }
                else
                {
                    resultInfo.Result = 0;
                    resultInfo.Body = result.M;
                }
            }
            catch (Exception ex)
            {
                resultInfo.Result = -1;
                resultInfo.Body = ex.Message;
            }
            return resultInfo;
        }

        /// <summary>
        /// 保存病历主题
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static OperateResult SetMedicalConfig(string data)
        {
            OperateResult resultInfo = new OperateResult();
            try
            {
                Medical_ConfigSoapClient service = new Medical_ConfigSoapClient();
                ResultHelperOfBoolean result = service.SetBase_Medical_ConfigByMedical_ID(data);
                if (!result.S)
                {
                    resultInfo.Result = 0;
                    resultInfo.Body = result.M;
                }
            }
            catch (Exception ex)
            {
                resultInfo.Result = -1;
                resultInfo.Body = ex.Message;
            }
            return resultInfo;
        }

        /// <summary>
        /// 删除病历主题
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static OperateResult DelMedicalConfig(int id)
        {
            OperateResult resultInfo = new OperateResult();
            try
            {
                Medical_ConfigSoapClient service = new Medical_ConfigSoapClient();
                ResultHelperOfBoolean result = service.DelBase_Medical_ConfigByMedical_ID(id);
                if (!result.S)
                {
                    resultInfo.Result = 0;
                    resultInfo.Body = result.M;
                }
            }
            catch (Exception ex)
            {
                resultInfo.Result = -1;
                resultInfo.Body = ex.Message;
            }
            return resultInfo;
        }
    }
}